<cfcomponent output="false">
	
	<cffunction name="savePaymentPlan" access="public" output="false" returntype="string">
		<cfargument name="fundID" required="true" />
		<cfargument name="installment_amount" required="true" />

		<cfset var local = {} />
		
		<cfif session.user.id eq "">
			<cfset $.session.addMessage("Not Logged in.") />
			<cfthrow message="not logged in" />
		</cfif>
		<cfset arguments.userID = session.user.id />
		
		<cfif arguments.amount eq "" or not isNumeric(arguments.amount) or arguments.amount eq 0>
			<cfthrow message="invalid amount [#arguments.amount#]" />
		</cfif>
		
		<cfif arguments.fundID eq "" or len(arguments.fundID) neq 17>
			<cfthrow message="invalid fundID [#arguments.fundID#]" />
		</cfif>
		
		<cfset local.paymentID = $.database.save(
			table="payment",
			id=arguments.paymentID,
			fund_id=arguments.fundID,
			payment_account_id=arguments.paymentAccountID,
			payment_status_id=arguments.paymentStatusID,
			amount=arguments.amount,
			user_id=arguments.userID,
			submitted_date=$.format.date(now())
		) />
		
		<cfreturn local.paymentID />

	</cffunction>
	
	<!--- --->

</cfcomponent>